package simorg;

import java.util.HashSet;
import java.util.Set;

class TestResult {
	public enum ExtraType {
		NONE, D, D_DOT, D_I_PAREN
	};

	ExtraType m_extra = ExtraType.NONE;

	private final Set<Test> m_testSet = new HashSet<Test>();

	private int m_result;

	private final String m_description;

	public TestResult(final int a_stringId) {
		final DatabaseInterface dbInterface = DatabaseInterface.getSingleton();

		m_result = a_stringId;
		m_description = dbInterface.getString(a_stringId);
	}

	public TestResult(final TestResult a_result) {
		m_description = a_result.m_description;
		m_extra = a_result.m_extra;
		m_result = a_result.m_result;
		m_testSet.addAll(a_result.m_testSet);
	}

	public void addTest(final Test a_test) {
		if (a_test != null) {
			m_testSet.add(a_test);
		}
	}

	public void dbgListTests() {
		System.out.print("Tests associated with result #" + m_result + ": ");

		for (final Test t : m_testSet) {
			System.out.print("#" + t.getId() + " ");
		}

		System.out.println();
	}

	public ExtraType getExtra() {
		return m_extra;
	}

	public int getResult() {
		return m_result;
	}

	public boolean hasTest(final Test a_test) {
		return m_testSet.contains(a_test);
	}

	public void setExtra(final ExtraType a_extra) {
		m_extra = a_extra;
	}

	public void setResult(final int a_result) {
		m_result = a_result;
	}
}
